<template>
  <div class="container-pt">
    <van-nav-bar left-arrow @click-left="$router.push('/cate')" fixed title="列表" />
    <van-tabs v-model="activeName" animated swipeable @click="onClick">
      <van-tab v-for="(item,index) in catename" :key="item.id" :name="item.id" :title="String(index)">
        <template #title> <van-icon name="more-o" /> {{ item.catename }} </template>
        <article-list :listid="$route.query.id" />
      </van-tab>
    </van-tabs>

  </div>
</template>

<script>
import articleList from '@/components/article-list.vue'
import { getcate } from '../api/cate';
export default {
  components: { articleList },
  data () {
    return {
      activeName: 0,
      catedetail: [],
      catename: [],

    };
  },
  created () {
    // this.params.cateid = this.$route.query.id

    this.getcatename()
  },
  methods: {
    // async getcatedetail () {

    //   const res = await getcatedetail(this.params)
    //   console.log(res);
    //   this.catedetail = res.data.list.data
    // },
    async getcatename () {
      const result = await getcate()
      console.log(result);

      // console.log(activeid.id);
      this.activeName = result.data.allCate[this.$route.query.index].id
      this.catename = result.data.allCate
    },
    // getagain(id){
    //   console.log(id);
    //   this.params.cateid=id
    //   this.getcatedetail()
    // },

    onClick (name,title) {
      console.log(name,title);
      this.$router.push(`/list?id=${ name }&index=${ title }`)
      // this.params.cateid = name.id
      // this.getcatedetail()
    },
  },
};
</script>

<style>
</style>